package cn.iocoder.yudao.module.enterprise.dal.mysql.company;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.enterprise.controller.admin.company.vo.CompanyExportReqVO;
import cn.iocoder.yudao.module.enterprise.controller.admin.company.vo.CompanyPageReqVO;
import cn.iocoder.yudao.module.enterprise.dal.dataobject.company.EnterpriseCompanyDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 企业信息 Mapper
 *
 * @author 谭万全
 */
@Mapper
public interface EnterpriseCompanyMapper extends BaseMapperX<EnterpriseCompanyDO> {

    default PageResult<EnterpriseCompanyDO> selectPage(CompanyPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EnterpriseCompanyDO>()
                .likeIfPresent(EnterpriseCompanyDO::getApplyUserName, reqVO.getApplyUserName())
                .eqIfPresent(EnterpriseCompanyDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(EnterpriseCompanyDO::getTel, reqVO.getTel())
                .eqIfPresent(EnterpriseCompanyDO::getEmail, reqVO.getEmail())
                .eqIfPresent(EnterpriseCompanyDO::getDept, reqVO.getDept())
                .eqIfPresent(EnterpriseCompanyDO::getJob, reqVO.getJob())
                .likeIfPresent(EnterpriseCompanyDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(EnterpriseCompanyDO::getCreditCode, reqVO.getCreditCode())
                .eqIfPresent(EnterpriseCompanyDO::getBusinessLicense, reqVO.getBusinessLicense())
                .eqIfPresent(EnterpriseCompanyDO::getIndustryType, reqVO.getIndustryType())
                .eqIfPresent(EnterpriseCompanyDO::getPostCode, reqVO.getPostCode())
                .eqIfPresent(EnterpriseCompanyDO::getBusinessStatus, reqVO.getBusinessStatus())
                .eqIfPresent(EnterpriseCompanyDO::getRegisteredCapital, reqVO.getRegisteredCapital())
                .betweenIfPresent(EnterpriseCompanyDO::getEstablishDate, reqVO.getBeginEstablishDate(), reqVO.getEndEstablishDate())
                .eqIfPresent(EnterpriseCompanyDO::getLegalPerson, reqVO.getLegalPerson())
                .eqIfPresent(EnterpriseCompanyDO::getScale, reqVO.getScale())
                .eqIfPresent(EnterpriseCompanyDO::getStatus, reqVO.getStatus())
                .eqIfPresent(EnterpriseCompanyDO::getAuthorizedStatus, reqVO.getAuthorizedStatus())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyType, reqVO.getCompanyType())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyPicture, reqVO.getCompanyPicture())
                .eqIfPresent(EnterpriseCompanyDO::getRegisteredAddress, reqVO.getRegisteredAddress())
                .eqIfPresent(EnterpriseCompanyDO::getBusinessScope, reqVO.getBusinessScope())
                .likeIfPresent(EnterpriseCompanyDO::getCompanyShortName, reqVO.getCompanyShortName())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyLogo, reqVO.getCompanyLogo())
                .eqIfPresent(EnterpriseCompanyDO::getIndustry, reqVO.getIndustry())
                .eqIfPresent(EnterpriseCompanyDO::getIntroduction, reqVO.getIntroduction())
                .eqIfPresent(EnterpriseCompanyDO::getEnvironment, reqVO.getEnvironment())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyAddress, reqVO.getCompanyAddress())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyCoordinate, reqVO.getCompanyCoordinate())
                .eqIfPresent(EnterpriseCompanyDO::getSubCompanyRelationshipCertificatePicture, reqVO.getSubCompanyRelationshipCertificatePicture())
                .eqIfPresent(EnterpriseCompanyDO::getSubCompanyRelationshipCertificateWord, reqVO.getSubCompanyRelationshipCertificateWord())
                .eqIfPresent(EnterpriseCompanyDO::getTopStatus, reqVO.getTopStatus())
                .betweenIfPresent(EnterpriseCompanyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .betweenIfPresent(EnterpriseCompanyDO::getLastLoginTime, reqVO.getBeginLastLoginTime(), reqVO.getEndLastLoginTime())
                .orderByDesc(EnterpriseCompanyDO::getId));
    }
    default List<EnterpriseCompanyDO> isExistence(String creditCode,List<String> authorizedStatus) {
        return selectList(new LambdaQueryWrapperX<EnterpriseCompanyDO>()
                .eqIfPresent(EnterpriseCompanyDO::getCreditCode, creditCode)
                .inIfPresent(EnterpriseCompanyDO::getAuthorizedStatus, authorizedStatus)
        );
    }

    default List<EnterpriseCompanyDO> selectList(CompanyExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EnterpriseCompanyDO>()
                .likeIfPresent(EnterpriseCompanyDO::getApplyUserName, reqVO.getApplyUserName())
                .eqIfPresent(EnterpriseCompanyDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(EnterpriseCompanyDO::getTel, reqVO.getTel())
                .eqIfPresent(EnterpriseCompanyDO::getEmail, reqVO.getEmail())
                .eqIfPresent(EnterpriseCompanyDO::getDept, reqVO.getDept())
                .eqIfPresent(EnterpriseCompanyDO::getJob, reqVO.getJob())
                .likeIfPresent(EnterpriseCompanyDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(EnterpriseCompanyDO::getCreditCode, reqVO.getCreditCode())
                .eqIfPresent(EnterpriseCompanyDO::getBusinessLicense, reqVO.getBusinessLicense())
                .eqIfPresent(EnterpriseCompanyDO::getIndustryType, reqVO.getIndustryType())
                .eqIfPresent(EnterpriseCompanyDO::getPostCode, reqVO.getPostCode())
                .eqIfPresent(EnterpriseCompanyDO::getBusinessStatus, reqVO.getBusinessStatus())
                .eqIfPresent(EnterpriseCompanyDO::getRegisteredCapital, reqVO.getRegisteredCapital())
                .betweenIfPresent(EnterpriseCompanyDO::getEstablishDate, reqVO.getBeginEstablishDate(), reqVO.getEndEstablishDate())
                .eqIfPresent(EnterpriseCompanyDO::getLegalPerson, reqVO.getLegalPerson())
                .eqIfPresent(EnterpriseCompanyDO::getScale, reqVO.getScale())
                .eqIfPresent(EnterpriseCompanyDO::getStatus, reqVO.getStatus())
                .eqIfPresent(EnterpriseCompanyDO::getAuthorizedStatus, reqVO.getAuthorizedStatus())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyType, reqVO.getCompanyType())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyPicture, reqVO.getCompanyPicture())
                .eqIfPresent(EnterpriseCompanyDO::getRegisteredAddress, reqVO.getRegisteredAddress())
                .eqIfPresent(EnterpriseCompanyDO::getBusinessScope, reqVO.getBusinessScope())
                .likeIfPresent(EnterpriseCompanyDO::getCompanyShortName, reqVO.getCompanyShortName())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyLogo, reqVO.getCompanyLogo())
                .eqIfPresent(EnterpriseCompanyDO::getIndustry, reqVO.getIndustry())
                .eqIfPresent(EnterpriseCompanyDO::getIntroduction, reqVO.getIntroduction())
                .eqIfPresent(EnterpriseCompanyDO::getEnvironment, reqVO.getEnvironment())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyAddress, reqVO.getCompanyAddress())
                .eqIfPresent(EnterpriseCompanyDO::getCompanyCoordinate, reqVO.getCompanyCoordinate())
                .eqIfPresent(EnterpriseCompanyDO::getSubCompanyRelationshipCertificatePicture, reqVO.getSubCompanyRelationshipCertificatePicture())
                .eqIfPresent(EnterpriseCompanyDO::getSubCompanyRelationshipCertificateWord, reqVO.getSubCompanyRelationshipCertificateWord())
                .eqIfPresent(EnterpriseCompanyDO::getTopStatus, reqVO.getTopStatus())
                .betweenIfPresent(EnterpriseCompanyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .betweenIfPresent(EnterpriseCompanyDO::getLastLoginTime, reqVO.getBeginLastLoginTime(), reqVO.getEndLastLoginTime())
                .orderByDesc(EnterpriseCompanyDO::getId));
    }

}
